/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package entities;

import java.util.Date;
import org.json.JSONObject;
import utilities.Key;
import utilities.Utility;

/**
 *
 * @author olawale
 */
public final class Status {

    public Status(String resultString) throws Exception{
        JSONObject result = new JSONObject(resultString);

        createdAt = Utility.parseDate(result.optString(Key.created_at));
        id = result.optLong(Key.id, -1);
        text = result.optString(Key.text);
        source = result.optString(Key.source);
        truncated = result.optBoolean(Key.truncated);
        favourited = result.optBoolean(Key.favorited);
        inReplyToStatusId = result.optLong(Key.in_reply_to_status_id);
        inReplyToUserId = result.optLong(Key.in_reply_to_user_id);
        inReplyToScreenName = result.optString(Key.in_reply_to_screen_name);
        user = new User(result.getString(Key.user));
        retweetDetails = null;
        geo = null;
    }

    public final Date createdAt;
    public final long id;
    public final String text;
    public final String source;
    public final boolean truncated;
    public final long inReplyToStatusId;
    public final long inReplyToUserId;
    public final boolean favourited;
    public final String inReplyToScreenName;
    public final User user;
    public final ReTweet retweetDetails;
    public final Geo geo;


    public boolean isRetweet(){
        if(retweetDetails == null)
            return false;
        else
            return true;
    }
}
